/**
 1.export与export default均可用于导出常量、函数、文件、模块等
 2.在一个文件或模块中，export、import可以有多个，export default仅有一个
 3.通过export方式导出，在导入时要加{ }，export default则不需要
 4.
 (1) 输出单个值，使用export default
 (2) 输出多个值，使用export
 (3) export default与普通的export不要同时使用
 */
import { get, post, put } from './axios'

export function doLogin (params) {
  return post('login', {
    phone: params.phone,
    email: params.email,
    password: params.password,
    loginType: params.loginType,
    havePassword: params.havePassword,
    verificationCode: params.verificationCode
  })
}

export function sendVerificationCode (params) {
  return post('verification_code', {
    sendType: params.sendType,
    email: params.email,
    phone: params.phone,
    codeType: params.codeType
  })
}

export function updateUser (params) {
  return put('/user', {
    nickname: params.nickname,
    description: params.description
  })
}

export function resetPassword (params) {
  return put('/user/reset_password', {
    verificationCode: params.verificationCode,
    phone: params.phone,
    password: params.password
  })
}
export function authEmail (params) {
  return put('/user/auth_email', {
    verificationCode: params.verificationCode,
    email: params.email
  })
}

export function getUser () {
  return get('user')
}
